<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" />
		<meta name="format-detection" content="telephone=no, address=no, email=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="misapplication-tap-highlight" content="no" />
		<meta name="HandheldFriendly" content="true" />
		<title>设置新手机号</title>
		<link rel="stylesheet" href="../../css/mui.min.css" type="text/css" charset="utf-8" />
		<link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav mui-header">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">修改手机号</h1>
		</header>
		<div class="mui-content">
			<form class="mui-input-group">
				<div class="mui-input-row">
					<label style="width: 26.4%;">新手机号</label>
					<input type="text" class="mui-input-clear" id="mobile" placeholder="请填写手机号">
				</div>

				<div style="margin-bottom:0.29rem;overflow: hidden;">
					<div class="mui-input-row" style="float:left;width:61.40625%;margin-bottom:0px;">
						<label style="width:43%">验证码</label>
						<input type="text" class="mui-input-clear" id="vcode" placeholder="验证码" style="width:57%">
					</div>
					<button type="button" class="mui-btn sendvcode" id="sendMsg">获取验证码</button>
				</div>

				<div id="message" style="color:#f00" class="none transition">
					<label>用户名或者密码错误</label>
				</div>

				<div class="mui-button-row">
					<button type="button" class="mui-btn mui-btn-primary mui-btn-full" id="nextStep" style="height:44px;background:#f1c40f;color:#fff;border-color:#f1c40f">确认</button>
				</div>

			</form>
		</div>

	</body>
	<script src="../../js/resize.js"></script>
	<script src="../../js/ajaxFun.js"></script>
	<script src="../../js/mui.min.js"></script>
	<script src="../../js/app.js"></script>
	<script>
		(function($, doc) {
			$.plusReady(function() {
				plus.nativeUI.closeWaiting();
				/*获取发送给新手机号的验证码*/
				app.sendVcode('03'); /*修改密码*/
				var nextStep = document.getElementById("nextStep");
				nextStep.addEventListener('tap', function() {
					var vcode = document.getElementById("vcode").value;
					var mobile = document.getElementById("mobile").value;
					if(!mobile) {
						plus.nativeUI.alert('请填写手机号！');
						return false;
					} else {
						if(!app.checkTel(mobile)) {
							plus.nativeUI.alert('请填写正确的手机号！');
							return false;
						}
					}
					/*先验证手机号码是否已经存在*/
					ajaxFun.postFun(baseUrl + 'dealersController/getJudgePhone.do', {
						mobile: mobile,
					}, '', function(d) {
						if(d.msg == '手机号不存在') {
							if(!vcode) {
								plus.nativeUI.alert('请填写验证码！');
								return false;
							}
							var data = {
								mobile: mobile,
								verificationCode: vcode
							}
							ajaxFun.postFun(baseUrl + 'traderInfoController/editPhone.do', data, '', function() {
								var users = app.getUser('$users');
								users.mobile = mobile;
								app.setUser(users);
								openWindow('index.html', 'main-jxs');
							})
						}else{
							plus.nativeUI.alert('已有经销商使用过该手机号！');
						}
					})

				})
			})
		}(mui, document))
	</script>

</html>